package com.xiaoshuidi.cloud.module.member.controller.app.auth;

import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.module.member.controller.app.auth.vo.FadadaCallbackReqVO;
import com.xiaoshuidi.cloud.module.member.controller.app.auth.vo.MemberAuthGetVerifyReqVO;
import com.xiaoshuidi.cloud.module.member.enums.ApiConstants;
import com.xiaoshuidi.cloud.module.member.service.user.MemberAuthenticationService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.security.PermitAll;
import javax.validation.Valid;

@Tag(name = "租客APP - 用户个人中心")
@RestController
@RequestMapping(ApiConstants.NAME + "/real-name-auth")
@RequiredArgsConstructor
@Validated
public class MemberAuthenticationController {
    private final MemberAuthenticationService memberAuthenticationService;

    @PostMapping("/get-verify-url")
    @Operation(summary = "获取个人实名认证地址")
    public CommonResult<String> getMemberVerifyUrl(@Valid @RequestBody MemberAuthGetVerifyReqVO reqVO) {
        String url = memberAuthenticationService.getMemberVerifyUrl(reqVO);
        return CommonResult.success(url);
    }


    @PermitAll
    @PostMapping("/auth-notify")
    @Operation(summary = "法大大实名认证的回调")
    public CommonResult<Boolean> handlerFadadaCallBack(FadadaCallbackReqVO reqVO) {
        return CommonResult.success(memberAuthenticationService.handlerFadadaCallBack(reqVO));
    }

}
